﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Bling.DSL;
using Bling.WPF;
using Bling.Util;
using Bling.Shaders;
using System.Windows.Media.Imaging;

namespace Bling.Tutorial {
  public class RipplesTest : Canvas {
    public static readonly ImageBrushBl Autumn = new ImageBrush(new BitmapImage("Resources/Autumn.jpg".MakePackUri(typeof(RipplesTest))));
    public static readonly ImageBrushBl Desert = new ImageBrush(new BitmapImage("Resources/Dock.jpg".MakePackUri(typeof(RipplesTest))));

    public RipplesTest() {
      CanvasBl MainCanvas = this;
      MainCanvas.Background = Brushes.White;
      var Center = new ThumbBl(MainCanvas) {
        CanDrag = true, CenterPosition = MainCanvas.CenterSize, Background = Brushes.Red,
        ToolTip = "Center", ZIndex = 1,
      };
      var Amplitude = new LabelSliderBl(MainCanvas) {
        ZIndex = 1, Width = MainCanvas.Width, Left = 0,
        Slider = { Minimum = 0d, Maximum = 1d, Value = .1, },
        Bottom = MainCanvas.Height, LabelName = "Amplitude",
      };
      var Frequency = new LabelSliderBl(MainCanvas) {
        ZIndex = 1, Width = MainCanvas.Width, Left = 0,
        Minimum = 0d, Maximum = 100d, Value = 50,
        Bottom = Amplitude.Top, LabelName = "Frequency",
      };
      var Phase = new LabelSliderBl(MainCanvas) {
        ZIndex = 1, Width = MainCanvas.Width, Left = 0,
        Minimum = 0d, Maximum = 10d, Value = 0,
        Bottom = Frequency.Top, LabelName = "Phase",
      };
      var Center0 = Center / MainCanvas.Size;

      var Canvas0 = new CanvasBl(MainCanvas) {
        Size = MainCanvas.Size, LeftTop = new Bling.Core.PointBl(0, 0), ZIndex = 0, Background = Autumn,
        Effect = { Custom = ShaderLib.Ripple(Center0, Amplitude, Frequency, Phase), },
      };
    }
  }
}
